package butines.game;

public class Cooldown {
	
	private float maxTimeWait;
	private float timeWait;
	
	public Cooldown() {
		
	}
	
	public Cooldown(float maxTimeWait) {
		this.timeWait = 0;
		this.maxTimeWait = maxTimeWait;
	}
		
	public float getTimeWait() {
		return (timeWait < 0) ? 0 : timeWait;
	}
	
	public float getTimeWaitPer(){
		return getTimeWait() / maxTimeWait;
	}
	
	public void setMaxTimeWait(float maxTimeWait) {
		this.maxTimeWait = maxTimeWait;
	}

	public float getMaxTimeWait() {
		return maxTimeWait;
	}
	
	public boolean isReady() {
		return timeWait <= 0;
	}
	
	public boolean isLocked() {
		return timeWait > 0;
	}
	
	public void refresh() {
		timeWait = 0;
	}
	
	public void lock() {
		timeWait = maxTimeWait;
	}
	
	public void update(float tpf) {
		if (timeWait > 0) {
			timeWait -= tpf;
		}
	}

}